import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controller/books.dart';
import '../../themes/appTheme.dart';

class BooksDataList extends StatelessWidget {
  BooksDataList({Key? key}) : super(key: key);
  final BooksController _booksController = Get.find();

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        ///////////"BOOKS" LISTS TAG//////////
        Container(
          margin: EdgeInsets.only(right: 12.0, bottom: 12.0),
          child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('Books'.tr,
                    style: TextStyle(
                      fontFamily: 'Montserrat',
                      color: Colors.white,
                      letterSpacing: 1,
                      fontSize: 18.0,
                    )),
                ElevatedButton(
                    style: ButtonStyle(
                        minimumSize:
                            MaterialStateProperty.all(Size(120.0, 30.0))),
                    child: Text(
                      'More'.tr,
                      style: TextStyle(
                          fontFamily: 'Montserrat',
                          fontSize: 12.0,
                          color: Get.isDarkMode
                              ? Get.theme.primaryColorDark
                              : Get.theme.primaryColorLight),
                    ),
                    onPressed: () {
                      if (GetPlatform.isWeb) {
                        Get.toNamed('/schooladmin/library');
                      } else {
                        Get.offAllNamed('/schooladmin/library');
                      }
                    }),
              ]),
        ),

        _booksController.obx(
          (data) {
            if (_booksController.booksDataSummary.value.result != null) {
              return Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  ///////////////TOTAL BOOKS DATA BLOCK///////////////
                  Expanded(
                    child: Container(
                      margin: EdgeInsets.only(right: 6.0),
                      decoration: BoxDecoration(
                        color: Get.isDarkMode
                            ? AppTheme.colors.darkTheme2
                            : Get.theme.primaryColorDark.withOpacity(0.1),
                        borderRadius: BorderRadius.circular(
                          6.0,
                        ),
                        boxShadow: [
                          BoxShadow(
                            blurRadius: 1,
                            spreadRadius: 1,
                            color: Get.isDarkMode
                                ? Colors.transparent
                                : Colors.black.withOpacity(0.1),
                            offset: Offset(1, 1),
                          ),
                        ],
                      ),
                      child: Padding(
                        padding: const EdgeInsets.all(12.0),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.only(bottom: 3.0),
                              padding: EdgeInsets.symmetric(
                                horizontal: 12.0,
                                vertical: 1.0,
                              ),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? Colors.black
                                      : Colors.black.withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(9.0)),
                              child: Text(
                                "Total Books".tr,
                                maxLines: 1,
                                overflow: TextOverflow.fade,
                                style: TextStyle(
                                  fontFamily: 'Montserrat',
                                  fontSize: 14.0,
                                  color: Get.isDarkMode
                                      ? Get.theme.primaryColorDark
                                      : Get.theme.primaryColorLight,
                                ),
                              ),
                            ),
                            Text(
                              _booksController
                                  .booksDataSummary.value.result!.total
                                  .toString(),
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 27.0,
                                color: Colors.white,
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                  ),
                  ////////////////TOTAL SOCIAL STUDIES BOOKS BLOCK/////
                  Expanded(
                    child: Container(
                      margin: EdgeInsets.only(right: 6.0),
                      padding: EdgeInsets.all(12.0),
                      decoration: BoxDecoration(
                        color: Get.isDarkMode
                            ? AppTheme.colors.darkTheme2
                            : Get.theme.primaryColorDark.withOpacity(0.1),
                        borderRadius: BorderRadius.circular(
                          6.0,
                        ),
                        boxShadow: [
                          BoxShadow(
                            blurRadius: 1,
                            spreadRadius: 1,
                            color: Get.isDarkMode
                                ? Colors.transparent
                                : Colors.black.withOpacity(0.1),
                            offset: Offset(1, 1),
                          ),
                        ],
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            margin: EdgeInsets.only(bottom: 3.0),
                            padding: EdgeInsets.symmetric(
                              horizontal: 12.0,
                              vertical: 1.0,
                            ),
                            decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? Colors.black
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(9.0)),
                            child: Text(
                              "Social Studies".tr,
                              maxLines: 1,
                              overflow: TextOverflow.fade,
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight,
                              ),
                            ),
                          ),
                          Text(
                            _booksController.booksDataSummary.value.result!
                                .category!["Social Studies"]!
                                .toString(),
                            style: TextStyle(
                              fontFamily: 'Montserrat',
                              color: Colors.white,
                              fontSize: 27.0,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  ///////////////TOTAL SCIENCE BOOKS DATA BLOCK/////
                  Expanded(
                    child: Container(
                      margin: EdgeInsets.only(right: 6.0),
                      padding: EdgeInsets.all(12.0),
                      decoration: BoxDecoration(
                        color: Get.isDarkMode
                            ? AppTheme.colors.darkTheme2
                            : Get.theme.primaryColorDark.withOpacity(0.1),
                        borderRadius: BorderRadius.circular(
                          6.0,
                        ),
                        boxShadow: [
                          BoxShadow(
                            blurRadius: 1,
                            spreadRadius: 1,
                            color: Get.isDarkMode
                                ? Colors.transparent
                                : Colors.black.withOpacity(0.1),
                            offset: Offset(1, 1),
                          ),
                        ],
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            margin: EdgeInsets.only(bottom: 3.0),
                            padding: EdgeInsets.symmetric(
                              horizontal: 12.0,
                              vertical: 1.0,
                            ),
                            decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? Colors.black
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(9.0)),
                            child: Text(
                              "Science".tr,
                              maxLines: 1,
                              overflow: TextOverflow.fade,
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight,
                              ),
                            ),
                          ),
                          Text(
                            _booksController.booksDataSummary.value.result!
                                .category!["Science"]!
                                .toString(),
                            style: TextStyle(
                              fontFamily: 'Montserrat',
                              fontSize: 27.0,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  ////////////////TOTAL STORY BOOKS DATA BLOCK/////
                  Expanded(
                    child: Container(
                      margin: EdgeInsets.only(right: 6.0),
                      padding: EdgeInsets.all(12.0),
                      decoration: BoxDecoration(
                        color: Get.isDarkMode
                            ? AppTheme.colors.darkTheme2
                            : Get.theme.primaryColorDark.withOpacity(0.1),
                        borderRadius: BorderRadius.circular(
                          6.0,
                        ),
                        boxShadow: [
                          BoxShadow(
                            blurRadius: 1,
                            spreadRadius: 1,
                            color: Get.isDarkMode
                                ? Colors.transparent
                                : Colors.black.withOpacity(0.1),
                            offset: Offset(1, 1),
                          ),
                        ],
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            margin: EdgeInsets.only(bottom: 3.0),
                            padding: EdgeInsets.symmetric(
                              horizontal: 12.0,
                              vertical: 1.0,
                            ),
                            decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? Colors.black
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(9.0)),
                            child: Text(
                              "Stories".tr,
                              maxLines: 1,
                              overflow: TextOverflow.fade,
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight,
                              ),
                            ),
                          ),
                          Text(
                            _booksController.booksDataSummary.value.result!
                                .category!["Story"]!
                                .toString(),
                            style: TextStyle(
                              fontFamily: 'Montserrat',
                              fontSize: 27.0,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  ////////////////TOTAL POETRY & RHYME BOOKS DATA BLOCK/////
                  Expanded(
                    child: Container(
                      margin: EdgeInsets.only(right: 6.0),
                      padding: EdgeInsets.all(12.0),
                      decoration: BoxDecoration(
                        color: Get.isDarkMode
                            ? AppTheme.colors.darkTheme2
                            : Get.theme.primaryColorDark.withOpacity(0.1),
                        borderRadius: BorderRadius.circular(
                          6.0,
                        ),
                        boxShadow: [
                          BoxShadow(
                            blurRadius: 1,
                            spreadRadius: 1,
                            color: Get.isDarkMode
                                ? Colors.transparent
                                : Colors.black.withOpacity(0.1),
                            offset: Offset(1, 1),
                          ),
                        ],
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            margin: EdgeInsets.only(bottom: 3.0),
                            padding: EdgeInsets.symmetric(
                              horizontal: 12.0,
                              vertical: 1.0,
                            ),
                            decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? Colors.black
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(9.0)),
                            child: Text(
                              "Poetries & Rhymes".tr,
                              maxLines: 1,
                              overflow: TextOverflow.fade,
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight,
                              ),
                            ),
                          ),
                          Text(
                            _booksController.booksDataSummary.value.result!
                                .category!["Poetry & Rhymes"]!
                                .toString(),
                            style: TextStyle(
                              fontFamily: 'Montserrat',
                              fontSize: 27.0,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  )
                ],
              );
            } else {
              return Text("");
            }
          },
        ),
      ],
    );
  }
}
